#include "smallwindow.h"
#include "ui_smallwindow.h"

SmallWindow::SmallWindow(int r, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::SmallWindow)
{
    ui->setupUi(this);

    if (r == 0)         //constructor is passed two arguments to identify which operation this SmallWindow needs to do
    {                       // 0 is for adding a new user, 1 is for verifying identity
        this->ui->Title->setText("Add New User");
    }
    else if (r == 1)
    {
        this->ui->Add_Add->setText("Confirm");
        this->ui->Title->setText("Confirm: Enter your username and password.");
        this->ui->Add_username->setFocus();
    }
}

SmallWindow::~SmallWindow()
{
    delete ui;
}


void SmallWindow::on_Add_Add_clicked()
{
    newusername = this->ui->Add_username->text();
    newpassword = this->ui->Add_password->text();
    QWidget::close();
}

void SmallWindow::on_Add_Cancel_clicked()
{
    QWidget::close();
}

QStringList SmallWindow::returnInfo(QString confirmation)   //return information that the user gave
{
    if (confirmation == "0x1289")   //make sure the person requesting this data is the MainWindow class. this number is hard coded in the MainWindow class
    {
        QStringList toreturn;
        toreturn.append(newusername);
        toreturn.append(newpassword);
        return toreturn;
    }
    else
        return QStringList();//return an empty list if asked from other class not the MainWindow
}
